package mark.tom.friend.bean.bo;

import android.os.Parcel;
import android.os.Parcelable;
import mark.tom.friend.base.BeanConvert;
import mark.tom.friend.bean.db.AppInfoDO;
import mark.tom.friend.bean.vo.AppInfoVO;

public class AppInfoBO extends AppInfoVO implements Parcelable {

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.appName);
        dest.writeString(this.versionName);
        dest.writeString(this.packageName);
        dest.writeString(this.md5Fingerprint);
        dest.writeString(this.sha1Fingerprint);
    }

    public AppInfoBO() {
    }

    private AppInfoBO(Parcel in) {
        this.appName = in.readString();
        this.versionName = in.readString();
        this.packageName = in.readString();
        this.md5Fingerprint = in.readString();
        this.sha1Fingerprint = in.readString();
    }

    public static final Creator<AppInfoBO> CREATOR = new Creator<AppInfoBO>() {
        @Override
        public AppInfoBO createFromParcel(Parcel source) {
            return new AppInfoBO(source);
        }

        @Override
        public AppInfoBO[] newArray(int size) {
            return new AppInfoBO[size];
        }
    };

    public final static class AppInfoDOConvert extends BeanConvert<AppInfoBO, AppInfoDO> {
        @Override
        public AppInfoBO convert(AppInfoDO source) {
            AppInfoBO bo = new AppInfoBO();
            bo.setAppName(source.getAppName());
            bo.setPackageName(source.getPackageName());
            bo.setVersionName(source.getVersionName());
            bo.setMd5Fingerprint(source.getMd5Fingerprint());
            bo.setSha1Fingerprint(source.getSha1Fingerprint());
            return bo;
        }

        @Override
        public AppInfoDO unConvert(AppInfoBO original) {
            AppInfoDO appInfoDO = new AppInfoDO();
            appInfoDO.setAppName(original.getAppName());
            appInfoDO.setVersionName(original.getVersionName());
            appInfoDO.setPackageName(original.getPackageName());
            appInfoDO.setMd5Fingerprint(original.getMd5Fingerprint());
            appInfoDO.setSha1Fingerprint(original.getSha1Fingerprint());
            return appInfoDO;
        }
    }
}
